weave.init()
is called.
Traces
It’s important to store traces of LLM applications in a central database, both during development and in production. You’ll use these traces for debugging, and as a dataset that will help you improve your application. Weave will automatically capture traces for cohere-python. You can use the library as usual, start by callingweave.init()
:

We patch the Cohere
Client.chat
, AsyncClient.chat
, Client.chat_stream
, and AsyncClient.chat_stream
methods for you to keep track of your LLM calls.Wrapping with your own ops
Weave ops make results reproducible by automatically versioning code as you experiment, and they capture their inputs and outputs. Simply create a function decorated with@weave.op()
that calls into Cohere’s chat methods, and Weave will track the inputs and outputs for you. Here’s an example:

Create a Model
for easier experimentation
Organizing experimentation is difficult when there are many moving pieces. By using the Model
class, you can capture and organize the experimental details of your app like your system prompt or the model you’re using. This helps organize and compare different iterations of your app.
In addition to versioning code and capturing inputs/outputs, Model
s capture structured parameters that control your application’s behavior, making it easy to find what parameters worked best. You can also use Weave Models with serve
, and Evaluation
s.
In the example below, you can experiment with model
and temperature
. Every time you change one of these, you’ll get a new version of WeatherModel
.
